package com.minelx.statementsplus.parse;

import com.minelx.sequence.core.StringScanner;
import com.minelx.sqlstructures.statements.SelectBuilder;
import com.minelx.sqlstructures.statements.clause.Field;
import com.minelx.sqlstructures.statements.parse.select.FieldMatcher;
import com.minelx.sqlstructures.statements.parse.select.SelectBuilderParser;
import com.minelx.statementsplus.ChildSqlBuilder;

public class ChildSqlBuilderParser {
	public ChildSqlBuilder parse(String text) {
		StringScanner scanner = StringScanner.source(text);
		scanner.goes("2=>(");
		// FIXME 2021/7/5  wait for me!!!     only parse name, or not as
		Field field = new FieldMatcher().get(scanner).orElseThrow(RuntimeException::new);
		scanner.goes(")");

		SelectBuilder selectBuilder = new SelectBuilderParser().parse(scanner);
		return ChildSqlBuilder.create(field.getName(), selectBuilder);
	}
}
